﻿using System.Windows.Input;
using Bookvar.UI.Commands;

namespace Bookvar.UI.ViewModel
{
    partial class MainPageViewModel
    {
        private class UndoCommand : CommandModel
        {
            public UndoCommand()
                : base(ApplicationCommands.Undo)
            {
            }

            protected internal override void OnExecute(object sender, ExecutedRoutedEventArgs e)
            {
                ActionService.Undo();
            }

            protected internal override void OnCanExecute(object sender, CanExecuteRoutedEventArgs e)
            {
                e.CanExecute = ActionService.HasActionToUndo && ActionService.CanUndo;
                e.Handled = true;
            }
        }
    }
}
